package com.iflytek.jobs.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.iflytek.jobs.service.domain.TraineeJob;
import com.iflytek.jobs.service.service.ITraineeJobService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实习岗位跟踪Controller
 * 
 * @author chenhs
 * @date 2024-01-17
 */
@RestController
@RequestMapping("/jobs/traineejob")
public class TraineeJobController extends BaseController
{
    @Autowired
    private ITraineeJobService traineeJobService;

    /**
     * 查询实习岗位跟踪列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TraineeJob traineeJob)
    {
        startPage();
        List<TraineeJob> list = traineeJobService.selectTraineeJobList(traineeJob);
        return getDataTable(list);
    }

    /**
     * 导出实习岗位跟踪列表
     */
    @Log(title = "实习岗位跟踪", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TraineeJob traineeJob)
    {
        List<TraineeJob> list = traineeJobService.selectTraineeJobList(traineeJob);
        ExcelUtil<TraineeJob> util = new ExcelUtil<TraineeJob>(TraineeJob.class);
        util.exportExcel(response, list, "实习岗位跟踪数据");
    }

    /**
     * 获取实习岗位跟踪详细信息
     */
    @GetMapping(value = "/{trId}")
    public AjaxResult getInfo(@PathVariable("trId") Long trId)
    {
        return success(traineeJobService.selectTraineeJobByTrId(trId));
    }

    /**
     * 新增实习岗位跟踪
     */
    @Log(title = "实习岗位跟踪", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TraineeJob traineeJob)
    {
        return toAjax(traineeJobService.insertTraineeJob(traineeJob));
    }

    /**
     * 修改实习岗位跟踪
     */
    @Log(title = "实习岗位跟踪", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TraineeJob traineeJob)
    {
        return toAjax(traineeJobService.updateTraineeJob(traineeJob));
    }

    /**
     * 删除实习岗位跟踪
     */
    @Log(title = "实习岗位跟踪", businessType = BusinessType.DELETE)
	@DeleteMapping("/{trIds}")
    public AjaxResult remove(@PathVariable Long[] trIds)
    {
        return toAjax(traineeJobService.deleteTraineeJobByTrIds(trIds));
    }
}
